<?php
namespace app\mobile\controller;

use think\Request;
use think\Validate;
use \app\mobile\model\Domain;

class Index {

	function __construct() {
		// 不初始化默认写入，系统日志，初始化自定义日志路径
		// \think\Log::init(['type' => 'File', 'path' => RUNTIME_PATH . 'logs/']);
	}
	public function index()
	{
		$request = Request::instance();
		echo '请求方法：' . $request->method() . '<br/>';
		echo '资源类型：' . $request->type() . '<br/>';
		echo '访问地址：' . $request->ip() . '<br/>';
		echo '是否AJax请求：' . var_export($request->isAjax(), true) . '<br/>';
		echo '请求参数：';
		dump($request->param());
		echo '请求参数：仅包含name';
		dump($request->only(['name']));
		echo '请求参数：排除name';
		dump($request->except(['name']));
		return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[This is mobile]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
	}
	public function sql_query() {
		$rule = [
		    'name'  => 'require|max:25',
		    'age'   => 'number|between:1,120',
		    'email' => 'email',
		];

		$msg = [
		    'name.require' => '名称必须',
		    'name.max'     => '名称最多不能超过25个字符',
		    'age.number'   => '年龄必须是数字',
		    'age.between'  => '年龄只能在1-120之间',
		    'email'        => '邮箱格式错误',
		];

		$data = [
		    'name'  => 'thinkphp',
		    'age'   => 1000,
		    'email' => 'thinkphp@qq.com',
		];
		$validate = new Validate($rule, $msg);
		$result   = $validate->check($data);
		if(!$validate->check($data)){
		    dump($validate->getError());
		}
		// $res = Domain::get_search_list();
		// dump($res);
	}
}
